<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上下架商品</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f9f9f9;
            padding: 20px;
        }
        .container {
            max-width: 600px;
            margin: auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"],
        input[type="number"],
        input[type="file"],
        textarea,
        select {
            width: 100%;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .status {
            margin-top: 20px;
            text-align: center;
        }
    </style>
</head>
<body>

<div class="container">
    <h2>上下架商品</h2>
    <form id="product-form">
        <div class="form-group">
            <label for="productName">商品名称</label>
            <input type="text" id="productName" placeholder="请输入商品名称" required>
        </div>
        <div class="form-group">
            <label for="productDescription">商品描述</label>
            <textarea id="productDescription" placeholder="请输入商品描述" rows="4" required></textarea>
        </div>
        <div class="form-group">
            <label for="productPrice">商品价格 (元)</label>
            <input type="number" id="productPrice" placeholder="请输入商品价格" required min="0" step="0.01">
        </div>
        <div class="form-group">
            <label for="productStock">商品库存</label>
            <input type="number" id="productStock" placeholder="请输入商品库存" required min="0">
        </div>
        <div class="form-group">
            <label for="productImage">商品图片上传</label>
            <input type="file" id="productImage" accept="image/*" required>
        </div>
        <div class="form-group">
            <label for="productStatus">商品状态</label>
            <select id="productStatus" required>
                <option value="">请选择状态</option>
                <option value="上架">上架</option>
                <option value="下架">下架</option>
            </select>
        </div>
        <button type="submit">提交</button>
    </form>
    <div class="status" id="statusMessage"></div>
</div>

<script>
    document.getElementById('product-form').addEventListener('submit', function(event) {
        event.preventDefault(); // 防止表单提交
        const productName = document.getElementById('productName').value;
        const productDescription = document.getElementById('productDescription').value;
        const productPrice = document.getElementById('productPrice').value;
        const productStock = document.getElementById('productStock').value;
        const productStatus = document.getElementById('productStatus').value;

        const statusMessage = `商品 "${productName}" 已成功 ${productStatus}！\n描述: ${productDescription}\n价格: ${productPrice}元\n库存: ${productStock}`;
        document.getElementById('statusMessage').innerText = statusMessage;

        // 清空表单
        this.reset();
    });
</script>

</body>
</html>
